package com.example.spring03.cho3.mapper;

import com.example.spring03.cho3.pojo.SysUser;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface UserMapper {
    @Insert("INSERT INTO sys_user (usr_name , usr_password , usr_role_id , usr_flag ) values (#{usrName} , #{usrPassword} , #{usrRoleId} , #{usrFlag})")
    public void insert(SysUser user);
    @Delete("DELETE FROM sys_user WHERE usr_id = #{id}")
    public void delete(Long id);
    @Update("<script>"+
    "UPDATE sys_user"+
    "<set>"+
            "<if test=\"usrName != null\">usr_name = #{usrName} , </if>" +
            "            <if test=\"usrPassword != null\">password = #{usrPassword},</if>" +
            "            <if test=\"usrRoleId != null\">usr_role_id = #{usrRoleId},</if>" +
            "            <if test=\"usrFlag != null\">usr_flag = #{usrFlag},</if>"+
    "</set>"+
    "WHERE usr_id = #{usrId}"+
    "</sscript>")
    public void update(SysUser user);
    @Select("SELECT usr_id , usr_")
    public SysUser get(Long id);
    public List<SysUser>findAll();
}
